<?php include("DbConn.php");
      include("UserTestResult.php");

   print "<chart>\n";
   print "   <chart_type>column</chart_type>\n";

   $userId = $_REQUEST["user"];
   $db = UserResultDbWriter::getInstance();
   $userResults = $db->getUserHistory($userId);
   print "   <legend layout='hide' />\n";
   print "   <axis_value_label>\n";
   print "      <null/>\n";
   print "      <null/>\n";
   print "      <string>Time\r(in sec)</string>\n";
   print " 	<null/>\n";
   print "   </axis_value_label>\n";
   print "   <series bar_gap='50'/>\n";
   print "   <series_color>\n";
   foreach($userResults as $testResult) {
      print "      <color>";
      print $testResult->isCorrect? "00FF0C" : "FF0000";
      print "</color>\n";
   }
   print "   </series_color>\n";

   print "   <chart_data>\n";

   print "      <row>\n";
   print "         <null/>\n";
   print "         <string>Last 10 Questions</string>\n";
   print "      </row>\n";

   foreach($userResults as $testResult) {
      $correctStr = $testResult->isCorrect? "Correct!" : "Incorrect";
      print "      <row>\n";
      print "         <string>Time</string>\n";
      print "         <number tooltip='".$correctStr."\\rQuestion: ".$testResult->questionStr."\\rAnswer: ".$testResult->answerStr."\\rYour Answer: ".$testResult->userAnswer."\\rYour Time: ".$testResult->userTime." sec'>".$testResult->userTime."</number>\n";
      print "      </row>\n";
   }

   print "   </chart_data>\n";
   print "</chart>";

?>
